<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <section>爱好：
        <input type="checkbox">玩游戏
        <input type="checkbox">打麻将
        <input type="checkbox">游泳
        <input type="checkbox">健身
    </section>
    <button id="btn">全选</button>
    <button id="btn2">取消全选</button>
    <script src="/jquery.js"></script>
    <script>
        $('#btn').on('click', function () {
            //var a = $('input:checked');
            var b = $('input:not(:checked)');
            //a.prop('checked', false);
            b.prop('checked', true);
            //console.log(b);

        });
        $('#btn2').on('click', function () {
            //var a = $('input:checked');
            var b = $('input:checked');
            //a.prop('checked', false);
            b.prop('checked', false);
            //console.log(b);

        });
    </script>
</body>

</html>